#include <stdio.h>

//十进制转二进制
char * itobs(int num, char * str) {
    int i;
    static int size = 8 * sizeof(int);
    for (i = size - 1; i >= 0; i--, num >>= 1) {
        str[i] = (01 & num) + '0';
    }
    str[size] = '\0';
    return str;
}

int main()
{
	int int_num[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
	printf("十进制数为：\n");
	for(int i = 0; i < 16; i++)
	{
		printf("%d\t",int_num[i]);
	}

	printf("\n二进制数为：\n");
	char binary[1];
	char *out;
	for(int i = 0; i < 16; i++)
	{
		out = itobs(int_num[i], binary);
		printf("%s\t",out);
	}

	printf("\n八进制数为：\n");
	for(int i = 0; i < 16; i++)
	{
		printf("%o\t",int_num[i]);
	}
	
	printf("\n十六进制数为：\n");
	for(int i = 0; i < 16; i++)
	{
		printf("%X\t",int_num[i]);
	}

	printf("\n");

	return 0;
}
